<?php
/**
 *
 * User: wufeng
 * Date: 2020/03/01
 */

namespace app\xcxapi\controller\v1;
use app\common\controller\XcxController;
use app\xcxapi\service\TaskService;

class Task extends XcxController
{
	/**
	 * 作业列表
	 * User: wufeng
	 * Date: 2020/03/01
	 *
	 */
	public function taskLists()
	{
		if ($this->request->isPost()) {
			$params = $this->request->param();
			$list = (new TaskService($this->type))->taskLists($params);
			if (1 !== $list['code']) {
				$this->fail($list);
			}
			$this->win($list);
		}
		$this->fail('ILLEGAL_REQUEST');
	}

	/**
	 * 作业详情列表
	 * User: wufeng
	 * Date: 2020/03/01
	 *
	 */
	public function taskDetailLists()
	{
		if ($this->request->isPost()) {
			$params = $this->request->param();
			$list = (new TaskService($this->type))->taskDetailLists($params);
			if (1 !== $list['code']) {
				$this->fail($list);
			}
			$this->win($list);
		}
		$this->fail('ILLEGAL_REQUEST');
	}

	/**
	 * 作业详情
	 * User: wufeng
	 * Date: 2020/03/03
	 *
	 */
	public function taskDetail()
	{
		if ($this->request->isPost()) {
			$params = $this->request->param();
			$list = (new TaskService($this->type))->taskDetail($params);
			if (1 !== $list['code']) {
				$this->fail($list);
			}
			$this->win($list);
		}
		$this->fail('ILLEGAL_REQUEST');
	}

	/**
	 * 发布作业
	 * User: wufeng
	 * Date: 2020/03/01
	 *
	 */
	public function publishWork()
	{
		if ($this->request->isPost()) {
			$params = $this->request->param();
			$list = (new TaskService($this->type))->publishWork($params);
			if (1 !== $list['code']) {
				$this->fail($list);
			}
			$this->win($list);
		}
		$this->fail('ILLEGAL_REQUEST');
	}

	/**
	 * 发布作业批改
	 * User: wufeng
	 * Date: 2020/03/04
	 *
	 */
	public function publishWorkCorrection()
	{
		if ($this->request->isPost()) {
			$params = $this->request->param();
			$list = (new TaskService($this->type))->publishWorkCorrection($params);
			if (1 !== $list['code']) {
				$this->fail($list);
			}
			$this->win($list);
		}
		$this->fail('ILLEGAL_REQUEST');
	}

	/**
	 * 发布作业解析
	 * User: wufeng
	 * Date: 2020/03/04
	 *
	 */
	public function publishWorkAnalysis()
	{
		if ($this->request->isPost()) {
			$params = $this->request->param();
			$list = (new TaskService($this->type))->publishWorkAnalysis($params);
			if (1 !== $list['code']) {
				$this->fail($list);
			}
			$this->win($list);
		}
		$this->fail('ILLEGAL_REQUEST');
	}

	/**
	 * 查询学生作业
	 * User: wufeng
	 * Date: 2020/03/04
	 *
	 */
	public function queryStudentWork()
	{
		if ($this->request->isPost()) {
			$params = $this->request->param();
			$list = (new TaskService($this->type))->queryStudentWork($params);
			if (1 !== $list['code']) {
				$this->fail($list);
			}
			$this->win($list);
		}
		$this->fail('ILLEGAL_REQUEST');
	}

	/**
	 * 删除
	 * User: wufeng
	 * Date: 2020/03/01
	 *
	 */
	public function delWork()
	{
		if ($this->request->isPost()) {
			$params = $this->request->param();
			$list = (new TaskService($this->type))->delWork($params);
			if (1 !== $list['code']) {
				$this->fail($list);
			}
			$this->win($list);
		}
		$this->fail('ILLEGAL_REQUEST');
	}
}